package com.zmn.plat.services.impl.channel;

import java.util.List;
import java.util.Objects;

import com.zmn.plat.model.vo.channel.category.ChannelCategoryUnionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zmn.plat.common.constant.ProductConsts;
import com.zmn.plat.model.entity.category.ServCategAndCategTwoQuery;
import com.zmn.plat.model.entity.channel.ChannelServiceAreaCategory;
import com.zmn.plat.model.vo.channel.ChannelServiceAreaProductCategoryVo;
import com.zmn.plat.persistence.interfaces.channel.ChannelServiceAreaCategoryDAO;
import com.zmn.plat.services.interfaces.channel.ChannelServiceAreaCategoryService;

/**
 * 渠道区域服务分类
 *
 * @author xiangjunming
 * @since 2019 /08/19 12:15:26
 */
@Service
public class ChannelServiceAreaCategoryServiceImpl implements ChannelServiceAreaCategoryService {

    @Autowired
    private ChannelServiceAreaCategoryDAO channelServiceAreaCategoryDAO;

    @Override
    public ChannelServiceAreaCategory findByKey(Integer id) {
        return channelServiceAreaCategoryDAO.findByKey(id);
    }

    @Override
    public List<ChannelServiceAreaCategory> listByServiceAreaId(Integer serviceAreaId, Integer showType) {
        return channelServiceAreaCategoryDAO.listByServiceAreaId(serviceAreaId, showType);
    }

    @Override
    public List<Integer> listServiceAreaIdByChannelIdAndShowType(Integer channelId, Integer showType) {
        return channelServiceAreaCategoryDAO.listServiceAreaIdByChannelIdAndShowType(channelId, showType);
    }

    @Override
    public List<ChannelServiceAreaCategory> listByChannelIdAndShowTypeAndServCategIdsAndCategIds(Integer channelId, Integer showType, List<Integer> servCategIds, List<Integer> categIds) {
        return channelServiceAreaCategoryDAO.listByChannelIdAndShowTypeAndServCategIdsAndCategIds(channelId, showType, servCategIds, categIds);
    }

    @Override
    public List<ChannelServiceAreaProductCategoryVo> listByChannelIdAndCityIdAndShowType(Integer channelId, Integer cityId, Integer showType) {
        return channelServiceAreaCategoryDAO.listByChannelIdAndCityIdAndShowType(channelId, cityId, showType);
    }

    @Override
    public List<ChannelCategoryUnionVo> listByChannelIdAndCityIdAndServCategIdList(Integer channelId, Integer cityId, List<Integer> servCategIdList) {
        return channelServiceAreaCategoryDAO.listByChannelIdAndCityIdAndServCategIdList(channelId, cityId, servCategIdList);
    }

    @Override
    public List<ServCategAndCategTwoQuery> listServCategAndCategTwoQueryByChannelIdAndCityIdAndShowType(Integer channelId, Integer cityId, Integer showType) {
        if (Objects.equals(showType, ProductConsts.ERP_PRODUCT_TYPE)) {
            return channelServiceAreaCategoryDAO.listServCategAndCategTwoQueryByChannelIdAndCityId(channelId, cityId);
        } else {
            return channelServiceAreaCategoryDAO.listServCategAndShowCategTwoQueryByChannelIdAndCityId(channelId, cityId);
        }
    }

    @Override
    public int count(Integer channelId, Integer cityId, Integer showType) {
        return channelServiceAreaCategoryDAO.count(channelId, cityId, showType);
    }

    @Override
    public int updateByKey(ChannelServiceAreaCategory record) {
        return channelServiceAreaCategoryDAO.updateByKey(record);
    }

    @Override
    public int insert(ChannelServiceAreaCategory record) {
        return channelServiceAreaCategoryDAO.insert(record);
    }

    @Override
    public int insertBatch(List<ChannelServiceAreaCategory> list) {
        return channelServiceAreaCategoryDAO.insertBatch(list);
    }

    @Override
    public int deleteByKey(Integer id) {
        return channelServiceAreaCategoryDAO.deleteByKey(id);
    }

    @Override
    public int deleteByKeys(List<Integer> ids) {
        return channelServiceAreaCategoryDAO.deleteByKeys(ids);
    }

    @Override
    public int deleteByServiceAreaId(Integer serviceAreaId, Integer showType) {
        return channelServiceAreaCategoryDAO.deleteByServiceAreaId(serviceAreaId, showType);
    }

    @Override
    public int deleteByServiceAreaIdAndServCategId(Integer serviceAreaId, Integer servCategId, Integer showType) {
        return channelServiceAreaCategoryDAO.deleteByServiceAreaIdAndServCategId(serviceAreaId, servCategId, showType);
    }


    @Override
    public int deleteByServiceAreaIdsAndServCategId(List<Integer> serviceAreaIds, Integer servCategId, Integer showType) {
        return channelServiceAreaCategoryDAO.deleteByServiceAreaIdsAndServCategId(serviceAreaIds, servCategId, showType);
    }

    @Override
    public int deleteByServiceAreaIds(List<Integer> serviceAreaIds, Integer showType) {
        return channelServiceAreaCategoryDAO.deleteByServiceAreaIds(serviceAreaIds, showType);
    }

    @Override
    public Integer deleteByChannelId(Integer channelId) {
        return channelServiceAreaCategoryDAO.deleteByChannelId(channelId);
    }

    @Override
    public void copy(Integer originalChannelId, int targetChannelId, String operator) {

        channelServiceAreaCategoryDAO.copy(originalChannelId, targetChannelId, operator);
    }
}